// 修复了this 指针指向的问题；按照词法作用与绑定
// this 指向所在的对象(和java一样了)
var obj = {
    birth: 1990,
    getAge: function () {
        var b = this.birth; // 1990
        var fn = () => new Date().getFullYear() - this.birth; // this指向obj对象
        return fn();
    }
};
var age = obj.getAge(); // 25
console.log(age);


var obj2 = {
    birth: 1990,
    getAge: function () {
        var b = this.birth; // 1990
        var fn = function(){
         new Date().getFullYear() - this.birth; // this指向外部引用obj的对象(而不是obj对象)
        }
        return fn();

    }
};

var age2 = obj2.getAge(); 
console.log(age2);//undefined